#lang racket

;; By default, Racket doesn't have set-car! and set-cdr! functions.  The
;; following line allows us to use those:
(require r5rs)
;; Unfortunately, it does this by making cons return a "mutable pair"
;; instead of a "pair", which means that many built-ins may fail
;; mysteriously because they expect a pair, but get a mutable pair.
;; Re-define a few common functions in terms of car and friends, which
;; the above line make work with mutable pairs.
(define first car)
(define rest cdr)
(define second cadr)
(define third caddr)
;; We also tell DrRacket to print mutable pairs using the compact syntax
;; for ordinary pairs.
(print-as-expression #f)
(print-mpair-curly-braces #f)

;;
;; Problem 1: Identity problems
;;
(define (remove-additive-identity exp)
  'your-code-here)

(define (remove-multiplicative-identity exp)
  'your-code-here)


;;
;; Problem 2: Simpler simplifier
;;

; Write your simplifier abstraction here.

(define (simplify exp simplifier)
  'your-code-here)



;; ---- Pattern matching ----

;;
;; Problem 3: These laws are binding
;;

; Write your binding and mapping abstractions here.

(define (mapping-add-binding! mapping binding)
  'your-code-here)


;;
;; Problem 4: Matchmaker, matchmaker, make me a match...
;;
(define (match-position? exp)
  'your-code-here)
(define (match-position-name exp)
  'your-code-here)

(define (match-pattern pattern expression)
  'your-code-here)


;;
;; Problem 5: Don't make me repeat myself (optional)
;;

;(define (mapping-add-binding! mapping binding)
;  'updated-code-here)

;(define (match-pattern pattern expression)
;  'updated-code-here)


;;
;; Problem 6: Putting it all together
;;
(define (make-pattern-simplifier pattern transformer)
  'your-code-here)


;;
;; Problem 7: Pick a number, any number (optional)
;;


;;
;; Problem 8: Now you're just fixing for points (optional)
;;
